package com.security.spring.controller;

import com.security.spring.service.AuthorizationService;
import com.security.spring.web.rq.GetTokenMessageDTO;
import com.security.spring.web.rs.TokenMessageDTO;
import org.springframework.web.bind.annotation.*;

/**
 * @author Administrator
 */
@RestController
@RequestMapping("/member/auth/api/v1")
public class AuthorizationController extends BaseController {

    private final AuthorizationService authorizationService;

    public AuthorizationController(AuthorizationService authorizationService) {
        this.authorizationService = authorizationService;
    }

    /**
     * 根据短信验证码/微信code/苹果code/用户名密码获取临时调用凭证(必传app_token)
     *
     * @param getTokenMessageDTO
     * @return
     */
    @GetMapping("access_token")
    public TokenMessageDTO getTokenMessage(@RequestHeader("Authorization") String authorization, @RequestBody GetTokenMessageDTO getTokenMessageDTO) {
        //TODO:增加authorization校验
        return authorizationService.doAuth(getTokenMessageDTO);
    }

    /**
     * 根据手机号获取短信验证码(必传app_token)
     *
     * @return
     */
    @GetMapping("sms_code")
    public String getSMSCode(@RequestHeader("Authorization") String authorization, @RequestParam("mobile") String mobile) {
        return "";
    }

}
